#include "exampleLayout.h"
#include "LayoutDialog.h"
#include "InterpolationCenter.h"
#include "xVMRelationStruct.h"
#include <algorithm>

exampleLayout::exampleLayout(){
}
void exampleLayout::ImportParameter(std::string json)
{
	doLayout();
	LayoutDialog::getInstance()->hide();
}
void exampleLayout::doInitialize()
{
	_name = "example1";
	_type = "ALL";
	_description = "this is an example";
	_parameter = new ParameterCollector;
	_parameter->addParameter("1","example","textarea","");
}

void exampleLayout::doLayout(){
	vector<DIVA_VM*> vms = xVMRelationStruct::getInstance()->VMRS_getAllVM();
	sort(vms.begin(),vms.end(), [](DIVA_VM* a, DIVA_VM* b)
	{ return *a->get_vm_sizey() < *b->get_vm_sizey();});

	double xsize = *vms.at(0)->get_vm_sizex();

	Ogre::Vector3 pos = vms.at(0)->getPosition();

	for(int i=1;i<vms.size();i++){
		Ogre::Vector3 pos;
		pos.x = 0;
		pos.y = 0;
		pos.z = 0;
		vms.at(0)->setPosition(pos);
		pos.x = pos.x + xsize*i + 10;
		vms.at(i)->setPosition(pos);
	}
}



void exampleLayout::doDeinitialize()
{

}